package com.lnsf.entity;




import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;








@Entity
@Table(name = "Comments")
public class Comments {
	@TableGenerator(
			name = "commentsSeq",
			allocationSize = 1,
			initialValue = 1 ,
			pkColumnName = "Pk_name",
			pkColumnValue = "comments_id",
			valueColumnName = "Pk_value"
		)
	@Id
	@GeneratedValue(strategy=GenerationType.TABLE,generator="commentsSeq")
	private Integer commnetsId;
	
	@ManyToOne()
	@JoinColumn(name="user_id")
	private User user;
	
	@ManyToOne()
	@JoinColumn(name="good_id")
	private Goods goods;
	
	
	/*@ManyToOne()
	@JoinColumn(name = "parentComm")  
	private Comments parentComm;*/
	
	/*
	 * 修改成OneToMany映射关系
	 */
	@OneToMany(fetch=FetchType.EAGER)
	@JoinColumn(name="parent")
	private List<Comments> parent;
	
	
	
	private String content;
	
	
	

	public Integer getCommnetsId() {
		return commnetsId;
	}

	public void setCommnetsId(Integer commnetsId) {
		this.commnetsId = commnetsId;
	}

	

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}


	public Goods getGoods() {
		return goods;
	}

	public void setGoods(Goods goods) {
		this.goods = goods;
	}

	/*public Comments getParentComm() {
		return parentComm;
	}

	public void setParentComm(Comments parentComm) {
		this.parentComm = parentComm;
	}*/
	
	
	
	public String getContent() {
		return content;
	}

	public List<Comments> getParent() {
		return parent;
	}

	public void setParent(List<Comments> parent) {
		this.parent = parent;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Override
	public String toString() {
		return "Comments [commnetsId=" + commnetsId + ", user=" + user + ", goods=" + goods + ", parent=" + parent
				+ ", content=" + content + "]";
	}
	
	
}
